<?

$tmppath="../../";
REQUIRE ($tmppath."include/login.php");
REQUIRE ($tmppath.$templates."up.php");
REQUIRE($tmppath."protect/connect_jeu.php");

echo "<SCRIPT TYPE=\"text/javascript\" SRC=\"../../common_script.js\"></SCRIPT>";






IF (!empty($mode)){

IF ($categ!='0'){
  $categorie=$categ;
   $querytmp2="AND invention_categorie='$categorie'";
             }

}




 $nbr_invention=0;

$query="SELECT inv_id FROM sdcon_inv where inv_user=$_PERSO_ID";
$resultat2=mysql_query($query);
WHILE ($request2=mysql_fetch_array($resultat2)){
    if ($drap==1){ $querytmp.=" OR ";}ELSE{$querytmp.=" WHERE (";}
    $i=$request2[0];
    $invention[$i]=1;
    $querytmp.="invention_id=$i";
    $drap=1;     $nbr_invention++;
}//Fin du while pour les recherches en cours.
               /*

$query="SELECT con_invention FROM sdconnp where con_id=$userperso";
$resultat=mysql_query($query);
$tmp=mysql_fetch_row($resultat);
$inventiontmp=EXPLODE("/",$tmp[0]);
$nbr_invention=count($inventiontmp);


FOREACH($inventiontmp as $element){
    if ($drap==1){ $querytmp.=" OR ";}ELSE{$querytmp.=" WHERE (";}
    $i=$element;
    $invention[$i]=1;
    $querytmp.="invention_id=$i";
    $drap=1;
}    //Fin du foreach

           */

$query="SELECT invention_categorie FROM invention $querytmp ) AND invention_souscategorie='Base'";
$resultat=mysql_query($query);



//Afficher le menu du haut.
//*************************
echo"<BR><table width=\"300\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" CLASS=\"TD3\">
  <tr>
    <td><div align=\"center\">
        <form name=\"form1\" method=\"post\" action=\"\">
          <select name=\"categ\">
            <option value=\"0\">Tous</option>";

WHILE ($tmp=mysql_fetch_array($resultat)){
echo"<option value=\"$tmp[0]\">$tmp[0]</option>";


}


          echo"</select>
          <br>
          <input name=\"mode\" type=\"hidden\" id=\"mode\" value=\"1\">
          
          <input name=\"$SID\" type=\"hidden\" id=\"$SID\" value=\"$SID\">
          

          <BR><input type=\"submit\" name=\"Submit\" value=\"Visionner\">
        </form>
      </div></td>
  </tr>
</table>";








//Chercher les inventions
//***********************


$query="SELECT invention_id, invention_name, invention_icon, invention_categorie FROM invention $querytmp ) $querytmp2 ORDER BY invention_categorie,invention_name ";
$resultat=mysql_query($query);

ECHO "<BR><table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
ECHO"<table width=\"95%\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
  <tr>
    <td><table width=\"100%\" border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td width=\"50\" CLASS=\"TD3\"><div align=\"center\"><strong>Image</strong></div></td>
          <td CLASS=\"TD3\"><div align=\"center\"><strong>Nom</strong></div></td>
          <td CLASS=\"TD3\"><div align=\"center\"><strong>categorie</strong></div></td>
          <td CLASS=\"TD3\"><div align=\"center\"><strong>-</strong></div></td>
          <td CLASS=\"TD3\"><div align=\"center\"><strong>-</strong></div></td>
          <td CLASS=\"TD3\"><div align=\"center\"><strong>-</strong></div></td>
        </tr>";

$var_tmp=0;
$nbr_cat=0;

WHILE ($tmp=mysql_fetch_array($resultat)){

$nbr_cat++;
IF ($var_tmp==0){
$bgr="CLASS=\"TD1\"";
$var_tmp=1;

}
ELSE{
$bgr="CLASS=\"TD2\"";
$var_tmp=0;

}

//<img src=\"../../images/invention/$tmp[2]\">

ECHO"<tr>
          <td $bgr></td>
          <td $bgr><a href=\"../visualisation/include.php?p=view_invention&ID=$tmp[0]\" target=\"FRAME_DESC\" onclick=\"div_fenetre_app('DESCRIPTION_DIV');\">$tmp[1]</a></td>
          <td $bgr>$tmp[3]</td>
          <td $bgr>-</td>
          <td $bgr></td>
          <td $bgr></td>

          </tr>";





}

echo "</table></table><br>";

//Affichage des caracteristique des invention.
//********************************************
$nbr_invention--;

echo"<table width=\"300\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
  <tr>
    <td><div align=\"center\">Nombre d'invention total : $nbr_invention<br>" ;
    
IF (!empty($mode)){

IF ($categ!='0'){
 echo" Invention(s) de cat&eacute;gorie $categorie : $nbr_cat</div></td>";

             }

}






        



echo"</tr></table>";

?>

